<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
    <meta name="decorator" content="default"/>
    <meta charset="UTF-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0;" name="viewport"/>
<style>
    .form-horizontal .controls{
        margin-left: 0px;
    }
    .form-horizontal .control-label {
        width: 80px;
    }
    #jbox-content{
        width: 300px;
    }
</style>
	<script type="text/javascript">
		$(document).ready(function() {
			//$("#name").focus();
			$("#inputForm").validate({
				submitHandler: function(form){
                    if (CKEDITOR.instances.content.getData()==""){
                        top.$.jBox.tip('请填写新闻内容','warning');
                    }else{
                        loading('正在提交，请稍等...');
                        form.submit();
                    }
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
		});
        $(document).ready(function () {
            $('#file_upload').uploadify({
                'swf': '${ctxStatic}/uploadify/uploadify.swf',
                //'uploader'：若是上传路径
                'uploader': '${ctx}/oa/personSigns/saveContractFile',
                'buttonText': '请选择要上传的附件',
                'height': 25,
                'width': 150,
                'auto': false,
                'fileTypeExts': '*.*',
                "fileObjName": 'file',
                'multi': false,
                'onUploadSuccess': function (file, data, response) {
                    console.log(file);
                    //若是上传成功，跳转的页面
                    location.href = "${ctx}/oa/personSigns/list";
                },
                'onCancel': function () {
                    flag = false;
                },
                'onSelect': function () {
                    flag = true;
                },
                'onUploadStart': function (file) {
                    $("#file_upload").uploadify("settings", "formData", {
                        'name': $("#name").val(),'signName':$("#signName").val(),
                        'id':$("#id").val()
                    });
                }
            });
            $("#btnSubmit").on("click", function () {
                $('#file_upload').uploadify('upload', '*');
            })

        });
	</script>
    <link rel="stylesheet" href="${ctxStatic}/oaApp/css/oaApp.css"/>
    <style>
        #jbox-content{
            width: 300px;
        }
    </style>
</head>
<body>
<div class="title_Infor">
    <a href="${ctx}/login" class="pull-left"><img src="${ctxStatic}/oaApp/img/liucheng_Icon/fanhui.png"/>返回</a>

    <h3>新闻编辑</h3>
</div>
	<form:form id="inputForm" modelAttribute="oaNews" action="${ctx}/oa/oaNews/save" method="post" class="form-horizontal">
		<form:hidden path="id"/>
        <form:hidden path="auditFlag"/>
		<sys:message content="${message}"/>
        <%--<c:if test="${oaNews.auditFlag eq '1'}">
            <div class="control-group">
                <label class="control-label">&nbsp;</label>
                <div class="controls" style="color: red;font-size: 20px;">
                    已审核，不能再次修改。
                </div>
            </div>
        </c:if>--%>
		<div class="control-group" style="margin: 20px 0 10px 0;">
			<label class="control-label">标题：</label>
			<div class="controls">
				<form:input path="title" htmlEscape="false" cssStyle="width:180px" maxlength="200" />
			</div>
		</div>
        <div class="control-group">
            <label class="control-label">新闻审核官：</label>
            <div class="controls">
                <form:select path="auditMan" >
                    <form:option value="" label=""/>
                    <form:options items="${fno:getAuditManAllList()}" itemLabel="auditMan" itemValue="auditId" htmlEscape="false"/>
                </form:select>
                <span class="help-inline"><font color="red">*</font> 选择审核人代表此新闻需审核，不选则表示此新闻不需要审核</span>
            </div>
        </div>
        <div class="control-group">
            <label class="control-label">附件：</label>
            <div class="controls">
                <input type="file"  name="file_upload" id="file_upload" value="选择文件"/>
            <%--<form:hidden id="files" path="files" htmlEscape="false" maxlength="2000" class="input-xlarge"/>--%>
                <%--<sys:ckfinder input="files" type="files" uploadPath="/oa/oaNews" selectMultiple="true"/>--%>
            </div>
        </div>
        <div class="control-group">
            <label class="control-label">是否置顶:</label>
            <div class="controls">
                <form:radiobuttons path="isTopic"  items="${fns:getDictList('yes_no')}" itemLabel="label" itemValue="value" htmlEscape="false" value="${isTopic}"/>
            </div>
        </div>
        <div class="control-group">
            <label class="control-label">接受人：</label>
            <div class="controls">
                <sys:treeselect id="oaNewsRecord" name="oaNewsRecordIds" value="${oaNews.oaNewsRecordIds}" labelName="oaNewsRecordNames" labelValue="${oaNews.oaNewsRecordNames}"
                                title="用户" url="/sys/office/treeData?type=3" cssStyle="width:145px" notAllowSelectParent="true" checked="true"/>
                <span class="help-inline"><font color="red">*</font> </span>
            </div>
        </div>
        <div class="control-group">
            <label class="control-label">新闻内容</label>
        </div>
        <div class="control-group">
            <div class="controls">
                <form:textarea id="content" htmlEscape="true" path="content" rows="4" maxlength="200" class="input-xxlarge"/>
                <sys:ckeditor replace="content" uploadPath="/oa/news" />
            </div>
        </div>

		<div align="center">
            <c:if test="${oaNews.auditFlag ne '1'|| oaNews.createBy eq fns:getUser().id || oaNews.auditMan eq fns:getUser().id || fns:getUser().id eq '1'}">
			    <shiro:hasPermission name="oa:oaNews:edit"><input id="btnSubmit" class="btn btn-primary" style="width: 300px" type="submit" value="保 存"/>&nbsp;</shiro:hasPermission>
			</c:if>
            <input id="btnCancel" class="btn"  style="width:300px" type="button" value="返 回" onclick="history.go(-1)"/>
		</div>
	</form:form>
</body>
</html>